﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PPM.Blog.Domain.Core
{
    [Table("T_Role", Schema = "dbo")]
    public class Role
    {
        public Role()
        {
            this.Children = new HashSet<Role>();
        }
        [Key]
        public int Id { get; set; }

   
        public int? ParentId { get; set; }

        [Required]
        [StringLength(10)]
        public string Name { get; set; }

        [Required]
        [StringLength(10)]
        public string Code { get; set; }


        [StringLength(20)]
        public string Level { get; set; }

        [StringLength(20)]
        public string Path { get; set; }


        [StringLength(1000)]
        public string Description { get; set; }


        public int State { get; set; }

       
        public int CreatorId { get; set; }

        public DateTime CreateTime { get; set; }

        public int? LastModifierId { get; set; }

        public DateTime? LastModifyTime { get; set; }

        [ForeignKey("ParentId")]
        public virtual Role ParentRole { get; set; }

        [InverseProperty("ParentRole")]
        public virtual ICollection<Role> Children { get; set; }

        [ForeignKey("CreatorId")]

        public virtual User Creator { get; set; }


        [ForeignKey("LastModifierId")]
        public virtual User LastModifier { get; set; }

    }
}